POV-Ray : Newsgroups : povray.off-topic : Hypothesis: OO does nothing for reusability : Hypothesis: OO does nothing for reusability Server Time
7 Sep 2024 03:22:42 EDT (-0400)
  Hypothesis: OO does nothing for reusability  
From: Darren New
Date: 20 Aug 2008 12:43:31
Message: <48ac49b3$1@news.povray.org>
Has anyone ever actually found an OO library to be more "reusable" than 
the same thing would be (say) organized procedurally? Has anyone made 
significant reuse of classes by overriding methods the original authors 
hadn't intended to be overridable? I'm not saying OO is a bad way of 
organizing something that has "objects" in it (like a windowing system 
or a simulation), but that it doesn't automatically lead to greater 
"reusability" as so many promised when it first got popular. (I count 
"reuse" as the ability to take code already written and use it in ways 
not anticipated when it was written.)

I think macro processors and standards lead to much greater reusability. 
The C preprocessor (m4 et al) is used in lots of other places. The IEEE 
floating point standard and the ANSI standards and regular expression 
definitions and RFCs are highly reusable (look how much stuff goes over 
HTTP that shouldn't). Even "components" (a la .NET or COM) are more 
reusable at the programming language level than OO tends to be nowadays 
(altho even there it's difficult to use a particular component in 
unforseen ways). Filter programs are very reusable for things the 
original authors never thought of. Virtual machines seem to get a lot of 
unexpected reuse - Ruby ported to the JVM, Bartok compiling .NET 
assembler language into raw native code, etc. Systems where you plumb 
bits together (pipes and filters, plug-in architectures, message-passing 
paradigms) seem to lead to more reuse than expected.

But particular OO libraries are IME limited to doing exactly what they 
were designed to do, without really being any more extensible than a 
procedural language with carefully crafted callbacks. For the most part, 
it seems OO has exactly one benefit, which is that you can add a 
subclass that follows the same contract as the sibling classes, and you 
don't need to change the parent class or callers to deal with this. But 
this isn't "reuse", it's just "convenient callback specification."

(I remember many years ago realizing there was no routine in Smalltalk 
that took a point X and a line and told you what the closest point on 
that line to X was. So I figured out the geometry and algebra, wrote the 
routine, and thought "well, that was a PITA, but it's OO, so at least 
I'll never have to do it again."  How naive I was.)

-- 
Darren New / San Diego, CA, USA (PST)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.